package openase.audiosearch.comm;

import java.io.UnsupportedEncodingException;

public class StringFormatUtils {

	private StringFormatUtils() {
	}

	public static String getUtf8(byte[] bytes) {
		if (bytes == null) {
			return "";
		}
		try {
			return new String(bytes, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e); // Should never happen
		}
	}

	public static byte[] getUtf8(String str) {
		if (str == null) {
			return new byte[0];
		}
		try {
			return str.getBytes("UTF-8");
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e); // Should never happen
		}
	}

}
